cmake_minimum_required(VERSION 3.29)
project(LearnOpenGL)

set(CMAKE_CXX_STANDARD 20)

if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
endif()

# GLFW
include_directories(${CMAKE_SOURCE_DIR}/Vendor/glfw/include)
link_libraries(${CMAKE_SOURCE_DIR}/Vendor/glfw/lib-mingw-w64/libglfw3.a)

# GLAD
include_directories(${CMAKE_SOURCE_DIR}/Vendor/glad/include)
set(GLAD_SRC ${CMAKE_SOURCE_DIR}/Vendor/glad/src/glad.c)

# stb_image
include_directories(${CMAKE_SOURCE_DIR}/Vendor/stb_image)

# GLM
include_directories(${CMAKE_SOURCE_DIR}/Vendor/glm)

# Copy File
add_custom_target(
        CopyAssets ALL
        COMMAND ${CMAKE_COMMAND} -E copy_directory
        ${CMAKE_SOURCE_DIR}/Assets
        ${CMAKE_BINARY_DIR}/Assets
        COMMENT "Copying Assets folder to output directory"
)

# 01_Start
add_executable(Start 01_Start/main.cpp ${GLAD_SRC})


# 02_HelloTriangle
aux_source_directory(${CMAKE_SOURCE_DIR}/02_HelloTriangle 02_HelloTriangle_Source)
add_executable(HelloTriangle ${02_HelloTriangle_Source} ${GLAD_SRC})
add_dependencies(HelloTriangle CopyAssets)

# 03_DrawTwoObject
aux_source_directory(${CMAKE_SOURCE_DIR}/03_DrawTwoObject 03_DrawTwoObject_Source)
add_executable(DrawTwoObject ${03_DrawTwoObject_Source} ${GLAD_SRC})
add_dependencies(DrawTwoObject CopyAssets)

# 04_Shader
aux_source_directory(${CMAKE_SOURCE_DIR}/04_Shader 04_Shader_Source)
add_executable(Shader ${04_Shader_Source} ${GLAD_SRC})
add_dependencies(Shader CopyAssets)

# 05_Texture
aux_source_directory(${CMAKE_SOURCE_DIR}/05_Texture 05_Texture_Source)
add_executable(Texture ${05_Texture_Source} ${GLAD_SRC})
add_dependencies(Texture CopyAssets)


# 06_Transform
aux_source_directory(${CMAKE_SOURCE_DIR}/06_Transform 06_Transform_Source)
add_executable(Transform ${06_Transform_Source} ${GLAD_SRC})
add_dependencies(Transform CopyAssets)

# 07_CoordinateSystem
aux_source_directory(${CMAKE_SOURCE_DIR}/07_CoordinateSystem 07_CoordinateSystem_Source)
add_executable(CoordinateSystem ${07_CoordinateSystem_Source} ${GLAD_SRC})
add_dependencies(CoordinateSystem CopyAssets)

# 08_Camera
aux_source_directory(${CMAKE_SOURCE_DIR}/08_Camera 08_Camera_Source)
add_executable(Camera ${08_Camera_Source} ${GLAD_SRC})
add_dependencies(Camera CopyAssets)
